/**
 * Copyright (C) 2011-2012 Luca Li Greci
 *
 * This file is part of pojo-creator
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.pojocreator;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * This class represents the property field in the POJO object
 * 
 * @author Luca Li Greci
 *
 * @param <T> generic type to represent the field value
 */
public class Property < T > {
    private String name;
    private T value;

    /**
     * Create an instance of Property with the property's name and its value
     * 
     * @param property Name of the property
     * @param value Value of the property
     */
    public Property(String property, T value) {
        this.value = value;
        this.name = property;
    }

    /**
     * Return the property's name.
     * 
     * @return the property's name
     */
    public String getName() {
        return name;
    }

    /**
     * Return the property's value.
     * 
     * @return the property's value
     */
    public T getValue() {
        return value;
    }
  
    /**
     * Return the property name 
     * 
     * @return the property name
     */
    @Override
    public String toString() {
        return name;
    }
    
    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj);
    }

}
